﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE.Web.Betfair.Interface.Entities;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;

namespace BE.Web.Betfair.Interface.Requests
{
    /// <summary>
    /// Represents a Quest for retrieving child bet events of a given bet-event
    /// </summary>
    public sealed class BetEventByParentEventRequest : SessionBasedRequest<ReadOnlyCollection<BetEvent>>
    {
        [ContractInvariantMethod]
        void ObjectInvariant()
        {
            Contract.Invariant(this.ParentEvent != null);
            Contract.Invariant(this.Session != null);
        }

        /// <summary>
        /// Gets the type of the event which should be resolved.
        /// </summary>
        /// <value>The type of the event.</value>
        public BetEvent ParentEvent { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BetEventByTypeRequest"/> class.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="completedAction">The completed action.</param>
        /// <param name="parentEvent">The parent event for which the child events should be retrieved</param>
        public BetEventByParentEventRequest(BetEvent parentEvent, Session session, Action<ReadOnlyCollection<BetEvent>> completedAction) :
            base(session,completedAction)
        {
            #region conditions
            Contract.Requires<ArgumentNullException>(session != null);
            Contract.Requires<ArgumentNullException>(completedAction != null);
            Contract.Requires<ArgumentNullException>(parentEvent != null);
            Contract.Ensures(this.ParentEvent != null);
            Contract.Ensures(this.Session != null);
            #endregion

            this.ParentEvent = parentEvent;
        }
    }
}
